const { resolve } = require("path");
const { merge } = require("webpack-merge");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const baseConfig = require("./webpack.base");

module.exports = merge(baseConfig, {
  // 输出文件
  output: {
    path: resolve(__dirname, "../dist"),
    filename: "[name].bundle.js",
    clean: true, //清理dist
  },
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        {
          from: resolve(__dirname, "../public/"),
          to: "./",
          globOptions: {
            dot: true,
            gitignore: true,
            ignore: ["**/index.html"],
          },
        },
      ],
    }),
  ],
  mode: "production",
});
